home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / vec_mat / ray / README < prev    next >
Encoding:
Text File  |  1995-02-06  |  7.5 KB  |  159 lines

  1. C++ code augmenting the article
  2. "C++ Vector and Matrix Algebra Routines"
  3. by Jean-Francois Doue, h058@frhec1.hec.fr
  4. in "Graphics Gems IV", Academic Press, 1994
  5.  
  6.  
  7. This directory contains a very basic ray-tracer, programmed to
  8. demonstrate the advantage of using a C++ vector and matrix library
  9. called algebra3. The library makes programs easier to write and to
  10. debug.
  11.  
  12. This document briefly discusses the class hierarchy of the program and
  13. the format of the description files which must be passed to it. An
  14. appendix lists all the files in this directory and describes them
  15. briefly.
  16.  
  17. CLASS HIERARCHY
  18. ---------------
  19.  
  20.          |---> Camera
  21.          |
  22. Object3D ----> Primitive ----> Sphere
  23.          |               |
  24.          |               |
  25.          |               ----> Polyhedron
  26.          ----> Light
  27.  
  28. Scene3D
  29.  
  30. The main program just creates a new Scene3D (a collection of
  31. Object3Ds), parses it from a text description, and invokes the
  32. Scene3D::rayTrace method. The Scene3D returns an array of 24 bits
  33. pixels. It is up to the reader change the code so as to save the image
  34. in a format appropriate to his/her machine (the program can compute the
  35. images, but does not display them).
  36.  
  37. The ray-tracer is voluntarily very basic: it is only capable of
  38. rendering spheres and concave polyhedrons, lit by point lights. It uses
  39. Phong's reflection model, but is not recursive, does not do shadows,
  40. light attenuation, textures, etc ...  What should be of interest about
  41. the program is the way it is written, not what it is capable of.
  42.  
  43. FORMAT
  44. ------
  45.  
  46. 3D scenes can be parsed from text representation. The text
  47. representation is simply a list (in any order) of 3D objects (camera,
  48. sphere, polyhedron and light). The parsing method is very crude and
  49. does not check the accuracy of the description file thoroughly. The
  50. exact syntax for each possible type of 3D objects is:
  51.  
  52. Camera:
  53.  ______________________________________________________________
  54. |                              |                               |
  55. | text file                    | comments                      |
  56. |______________________________|_______________________________|
  57. |                              |                               |
  58. |   camera                     | - keyword;                    |
  59. |   | 0.0 0.5 4.0 |            | - position of the camera;     |
  60. |   | 1.0   0.0   0.0   0.0 |  | - orientation of the camera;  |
  61. |   | 0.0   1.0   0.0   0.0 |  |                               |
  62. |   | 0.0   0.0   1.0   0.0 |  |                               |
  63. |   | 0.0   0.0   0.0   1.0 |  |                               |
  64. |   | 60.0 60.0 |              | - field of view (in degrees); |
  65. |______________________________|_______________________________|
  66.  
  67. Sphere:
  68.  ______________________________________________________________
  69. |                              |                               |
  70. |   text file                  | comments                      |
  71. |______________________________|_______________________________|
  72. |                              |                               |
  73. |   sphere                     | - keyword;                    |
  74. |   | 0.0 0.5 4.0 |            | - position of the sphere;     |
  75. |   | 1.0   0.0   0.0   0.0 |  | - orientation of the sphere;  |
  76. |   | 0.0   1.0   0.0   0.0 |  |                               |
  77. |   | 0.0   0.0   1.0   0.0 |  |                               |
  78. |   | 0.0   0.0   0.0   1.0 |  |                               |
  79. |   | 0.9 1.0 1.0 |            | - color of the sphere;        |
  80. |   | 0.1 0.48 0.7 20.0 |      | - phong coefficients;         |
  81. |   2.0                        | - radius;                     |
  82. |______________________________|_______________________________|
  83.  
  84. Polyhedron:
  85.  ______________________________________________________________
  86. |                              |                               |
  87. | text file                    | comments                      |
  88. |______________________________|_______________________________|
  89. |                              |                               |
  90. |   polyhedron                 | - keyword;                    |
  91. |   | 0.0 0.5 4.0 |            | - position of the polyhedron; |
  92. |   | 1.0   0.0   0.0   0.0 |  | - orientation of the          |
  93. |   | 0.0   1.0   0.0   0.0 |  |   polyhedron;                 |
  94. |   | 0.0   0.0   1.0   0.0 |  |                               |
  95. |   | 0.0   0.0   0.0   1.0 |  |                               |
  96. |   | 0.9 1.0 1.0 |            | - color of the polyhedron;    |
  97. |   | 0.1 0.48 0.7 20.0 |      | - phong coefficients;         |
  98. |   10                         | - number of vertices;         |
  99. |   | -1.0 -1.0 -1.0 |         | - first vertex;               |
  100. |   |  1.0 -1.0 -1.0 |         | - second vertex;              |
  101. |       .......                |                               |
  102. |   |  0.0  1.8  1.0 |         | - last vertex;                |
  103. |   7                          | - number of facets;           |
  104. |   5 0 3 8 2 1                | - first facet (number of      |
  105. |                              |   vertices followed by the    |
  106. |                              |   index of each vertex in the |
  107. |                              |   facet);                     |
  108. |   5 4 5 6 9 7                | - second facet;               |
  109. |       .......                |                               |
  110. |   4 0 4 7 3                  | - last facet;                 |
  111. |______________________________|_______________________________|
  112.  
  113. Light:
  114.  ______________________________________________________________
  115. |                              |                               |
  116. |   text file                  | comments                      |
  117. |______________________________|_______________________________|
  118. |                              |                               |
  119. |   light                      | - keyword;                    |
  120. |   | 0.0 0.5 4.0 |            | - position of the light;      |
  121. |   | 1.0   0.0   0.0   0.0 |  | - orientation of the light;   |
  122. |   | 0.0   1.0   0.0   0.0 |  |                               |
  123. |   | 0.0   0.0   1.0   0.0 |  |                               |
  124. |   | 0.0   0.0   0.0   1.0 |  |                               |
  125. |   | 0.9 1.0 1.0 |            | - color of the light;         |
  126. |______________________________|_______________________________|
  127.  
  128. Comment lines (starting with the '%' sign) can be inserted in the text
  129. (between 3D objects only, not within the description of a 3D object
  130. !!!).
  131.  
  132.  
  133. APPENDIX
  134. --------
  135.  
  136. Camera.c        // Implementation of the camera class
  137. Camera.h        // Interface of the camera class
  138. Light.c         // Implementation of the point light class
  139. Light.h         // Interface of the point light class
  140. Makefile        // Unix makefile
  141. Object3D.c      // Implementation of the 3D object class
  142. Object3D.h      // Interface of the 3D object class
  143. Polyhedron.c    // Implementation of the concave polyhedron class
  144. Polyhedron.h    // Interface of the concave polyhedron class
  145. Primitive.c     // Implementation of the primitive class
  146. Primitive.h     // Interface of the primitive class
  147. README          // This file
  148. Scene3D.c       // Implementation of the 3D scene class
  149. Scene3D.h       // Interface of the 3D scene class
  150. Sphere.c        // Implementation of the sphere class
  151. Sphere.h        // Interface of the sphere class
  152. algebra3.c      // The vector and matrix library
  153. algebra3.h      // Include file of the vector and matrix library
  154. main.c          // Main program
  155. example.tiff    // A sample picture rendered with the program
  156. example.data    // The script to render example.tiff
  157. solver.c        // Math utilities by Jochen Schwarze (see Graphics Gems 1 for
  158. solver.h        // more details)
  159.